<template>
   <div>
      <div class="contBtn_left">
         <v-btn :btnConfig="btnConfig" @newWl="newWl" @btnSave="btnSave" @btnDelete="btnDelete"></v-btn>
      </div>
   </div>
</template>

<script>
import btn from "@/components/commons/TableTitle";

export default {
   name: "",
   props: {},
   data() {
      return {

         btnConfig: [
            {label: this.$t('out.newLogistics'), invalid: "newWl"},
            {label: this.$t('out.newExpress'), disabled: true, invalid: ""},
            {label: this.$t('common.save'), invalid: "btnSave"},
            {label: this.$t('common.delete'), invalid: "btnDelete"},
         ],

      }
   },
   methods: {
      newWl() {
         //需要写接口
      },
      async btnSave() {
         if (this.$parent.$refs.input.inputData.carriercode === "") {
            this.errorPlay();
            this.$message.error(this.$selectPlease("config.carrierCode"));
            return;
         }
         try {
            let res = await this.$api.post(`/SaveWL`, {
               whseid: this.$parent.whseid,
               opeuser: this.$parent.opeuser,
               users: this.$parent.users,
               shippingkey: this.$parent.$refs.input.inputData.shippingkey,
               carriercode: this.$parent.$refs.input.inputData.carriercode,
            })
            if (res.data.type === "error") {
               this.errorPlay();
               this.$message.error(res.data.msg);
            } else if (res.data.type === "success") {
               this.$parent.$refs.input.carriercodeFlag = true;
            }
         } catch (e) {
            this.$message.error(this.$t('app.err'));
            this.errorPlay();
         }
      },
      async btnDelete() {
         try {
            let res = await this.$api.post(`/DeleteWL`, {
               whseid: this.$parent.whseid,
               opeuser: this.$parent.opeuser,
               users: this.$parent.users,
               shippingkey: this.$parent.$refs.input.inputData.shippingkey,
            })
            if (res.data.type === "error") {
               this.$message.error(res.data.msg);
               this.errorPlay();
            } else if (res.data.type === "success") {
               //需要接口
            }
         } catch (e) {
            this.$message.error(this.$t('app.err'));
            this.errorPlay();
         }
      }
   },
   mounted() {
   },
   components: {
      "v-btn": btn,
   }
}
</script>

<style scoped>

</style>
